import { getRoles } from '@/api/role'

const state = {
  roleList: []
}

const mutations = {
  CHANG_ROLESLIST(state, roleList) {
    state.roleList = roleList
  }
}

const actions = {
  async changeRolesList({commit}) {
    const data = await getRoles()
    if (data.meta.status !== 200) { return this.$message.error('获取角色列表失败') }
    commit('CHANG_ROLESLIST', data.data)
  }
}

export default {
  state,
  actions,
  mutations
}
